package gui.houseeditor;

import java.util.LinkedList;
import java.util.List;

public abstract class AbstractHouseModel implements HouseModel{

    protected List<HouseDataListener> listeners=new LinkedList<HouseDataListener>();
    protected int width,height;
    
    public AbstractHouseModel(int w,int h){
        width=w;
        height=h;
    }
    public void addWorldDataListener(HouseDataListener l){
        listeners.add(l);
    }
    
    public HouseDataListener[] getMazeDataListeners(){
        return (HouseDataListener[])listeners.toArray();
    }
    
    public void removeWorldDataListener(HouseDataListener l){
        listeners.remove(l);
    }
    
    protected void fireValueChanged(Object source,int x,int y){
        final HouseDataEvent e=new HouseDataEvent(source,x,y);
        for(HouseDataListener l:listeners)
            l.valueChanged(e);

   }
    
    public int getWidth(){
        return width;
    }

    public int getHeight(){
        return height;
    }
    
    public abstract HouseObject getCell(int x,int y);
    public abstract void setCell(HouseObject o,int x,int y);
    
}
